﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;

namespace BZZ.Web.book
{
    public partial class BookList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            showInfoList();
        }

        /// <summary>
        /// 数据列表
        /// </summary>
        protected void showInfoList()
        {
            #region 变量定义
            DataSet dset = new DataSet();
            BZZ.DAL.book dal = new BZZ.DAL.book();
            System.Collections.Generic.List<System.Data.SqlClient.SqlParameter> paraList = new List<System.Data.SqlClient.SqlParameter>();
            string dataFields = ""; //读取的字段名，空为所有
            string strWhere = "1=1"; //查询子句
            string strOrderBy = " id desc"; //排序参数，如果需要分页，则必填 
            #endregion

            #region 查询条件
            //string strId = txtQryId.Text.Trim();
            //if (strId != "" && strId != null )
            //{
            //    strWhere += " and id=@id";
            //    paraList.Add(new System.Data.SqlClient.SqlParameter("@id", strId));
            //} 
            //string strCata = txtQryCata.Text.Trim();
            //if (strCata != null && strCata != "")
            //{
            //    strWhere += " and cata=@cata";
            //    paraList.Add(new System.Data.SqlClient.SqlParameter("@cata", strCata));
            //}
            //string strBookName = txtQryBookName.Text.Trim();
            //if (strBookName != null && strBookName != "")
            //{
            //    strWhere += " and bookName=@bookName";
            //    paraList.Add(new System.Data.SqlClient.SqlParameter("@bookName", strBookName));
            //}
            //string strAbout = txtQryAbout.Text.Trim();
            //if (strAbout != "" && strAbout != null )
            //{
            //    strWhere += " and about=@about";
            //    paraList.Add(new System.Data.SqlClient.SqlParameter("@about", strAbout));
            //} 
            //string strSortid = txtQrySortid.Text.Trim();
            //if (strSortid != "" && strSortid != null )
            //{
            //    strWhere += " and sortid=@sortid";
            //    paraList.Add(new System.Data.SqlClient.SqlParameter("@sortid", strSortid));
            //} 
            //string strExt1 = txtQryExt1.Text.Trim();
            //if (strExt1 != "" && strExt1 != null )
            //{
            //    strWhere += " and ext1=@ext1";
            //    paraList.Add(new System.Data.SqlClient.SqlParameter("@ext1", strExt1));
            //} 
            //string strExt2 = txtQryExt2.Text.Trim();
            //if (strExt2 != "" && strExt2 != null )
            //{
            //    strWhere += " and ext2=@ext2";
            //    paraList.Add(new System.Data.SqlClient.SqlParameter("@ext2", strExt2));
            //} 
            #endregion

            #region 分页控件绑定
            int pageSize = 30; //分页每页记录个数
            int totalRecourd = 0; //总记录个数
            int currentPage = 1; //当前页码
            try { currentPage = int.Parse(Request.QueryString["p"]); }
            catch { }

            totalRecourd = dal.GetCount(strWhere, paraList);
            dset = dal.GetDatasetByPageSql(currentPage, pageSize, strWhere, strOrderBy, paraList, dataFields);
            if (dset != null && dset.Tables[0].Rows.Count > 0)
            {
                rptInfoList.DataSource = dset;
                rptInfoList.DataBind();
                //litPager.Text = LIB.pager.getPageHtml(this, totalRecourd, pageSize);
            }
           
            #endregion
            #region 单页数据绑定
            //strWhere += " " + strOrderBy;
            //dset = dal.GetDataset(strWhere, paraList, dataFields);
            //if (dset.Tables[0].Rows.Count > 0)
            //{
            //    rptInfoList.DataSource = dset;
            //    rptInfoList.DataBind();
            //}
            //else
            //{
            //    litPromptMessage.Text = "没有查询到相关记录";
            //} 
            #endregion

        }

    }
}
